package api

import (
	"ball/api/handler"
	"ball/api/middle"
	"ball/pkg"
	"github.com/gin-gonic/gin"
)

func Router(r *gin.Engine) {
	r.Use(middle.Cors())
	api := r.Group("api")
	{
		user := api.Group("/user")
		{
			user.POST("/login", handler.Login)
		}
		chat := api.Group("/chat")
		{
			chat.Use(pkg.JWTAuth("2210a"))
			chat.GET("/chat", handler.Chat)
			chat.POST("/addchat", handler.AddChat)
		}

		video := api.Group("/video")
		{
			video.POST("/addvideo", handler.AddVideo)
			video.POST("/listvideo", handler.ListVideo)
			video.POST("/info", handler.InfoVideo)
			video.POST("/search", handler.SearchVideo)
		}
	}
}
